package com.cms.recursoshumanos.ui.user.poliza;


import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.decor.BorderFactory;

import com.cms.recursoshumanos.cache.UserInfoCache;
import com.cms.recursoshumanos.component.StringListStyleButtonField;
import com.cms.recursoshumanos.component.base.CustomListElement;
import com.cms.recursoshumanos.constant.Constant;
import com.cms.recursoshumanos.container.ForegroundManager;
import com.cms.recursoshumanos.container.ListStyleButtonSetManager;
import com.cms.recursoshumanos.container.ListStyleButtonSetScrollManager;
import com.cms.recursoshumanos.container.TwoColumnFieldManager;
import com.cms.recursoshumanos.engine.ScreenEngine;
import com.cms.recursoshumanos.handler.DetailPolizaScreenHandler;
import com.cms.recursoshumanos.handler.ListaFamiliarScreenHandler;
import com.cms.recursoshumanos.handler.ListaHospitalScreenHandler;
import com.cms.recursoshumanos.object.Poliza;
import com.cms.recursoshumanos.ui.RecursosHumanosScreen;
import com.cms.recursoshumanos.utilities.Tool;



/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class DetailPolizaScreen extends RecursosHumanosScreen implements FieldChangeListener
{
	public static DetailPolizaScreen instance = null;
	
	
	private Poliza laPoliza;
	private ForegroundManager _foreground;
	
	HorizontalFieldManager hfm;
	
	CustomListElement lblNombreSeguro, lblNroTlfSeguro1, 
						lblNroTlfSeguro2, lblNumeroPoliza,
						lblCantidadAsegurada, lblPrimaSeguro,
						lblFechaInic, lblFechaFin, lblRifSeguro,
						lblNombreCorredor, lblNroTlfCorredor1, 
						lblNroTlfCorredor2, lblEmailCorredor;
	TwoColumnFieldManager twoColumnManager;
	
	StringListStyleButtonField listOpcionEnvioCartaAval,
							    listOpcionInfoCartaAval,
								listOpcionClinicas,
								listOpcionBeneficiaros;
	
	LabelField lblOpcionesAdicionales,labelNombre,labelCaracteristica, lblInformacionCorredor, lblInformacionSeguro;
	Manager _content_poliza, _content_seguro, _content_corredor ;//, _bodyWrapper;
	
	ListStyleButtonSetScrollManager buttonSet;
	
	
	public static DetailPolizaScreen getInstance(Poliza laPoliza)
	{
		if (instance == null)
		{
			return new DetailPolizaScreen(laPoliza);
		}
		else
		{
			return instance;
		}
	}
	public DetailPolizaScreen(Poliza laPoliza) 
	{
		super(NO_VERTICAL_SCROLL | USE_ALL_HEIGHT);
		//refrescar_lista_choice();
		this.laPoliza = laPoliza;
		setComponents();
	}
	public void setComponents() 
	{
		setTitle("Detalle Poliza");
		_foreground = new ForegroundManager();
		//_bodyWrapper = new NegativeMarginVerticalFieldManager(USE_ALL_WIDTH);
		
		twoColumnManager = new TwoColumnFieldManager( Display.getWidth() / 2, USE_ALL_WIDTH );
        twoColumnManager.setBorder( BorderFactory.createBitmapBorder( new XYEdges( 10, 10, 10, 10 ), Bitmap.getBitmapResource( "border_simple_white.png" ) ) );
        twoColumnManager.setMargin( 6, 6, 6, 6 );
        twoColumnManager.setPadding( 6, 2, 2, 2 );
        
        labelNombre = new LabelField( "Poliza Nro." + this.laPoliza.getNumeroPoliza() , 
        								FIELD_HCENTER |
        								FIELD_VCENTER |
        								LabelField.USE_ALL_WIDTH |
        								DrawStyle.HCENTER |
        								DrawStyle.VCENTER);
        labelNombre.setFont(font_bold_8);
        
        twoColumnManager.add(labelNombre);
        
        labelCaracteristica = new LabelField("Informacion General", LabelField.HCENTER | FIELD_HCENTER);
		labelCaracteristica.setFont(font_italic_7);
        twoColumnManager.add ( labelCaracteristica );
		
		Field separator = new SeparatorField();
        separator.setMargin( 2, 0, 2, 0 );
        twoColumnManager.add( separator );

        _content_corredor = new ListStyleButtonSetManager();
        _content_poliza = new ListStyleButtonSetManager();
        _content_seguro = new ListStyleButtonSetManager();
        
        setListComponents();    
        
        lblOpcionesAdicionales = new LabelField("Opciones Adicionales", USE_ALL_WIDTH);
        lblOpcionesAdicionales.setFont(font_bold_6);
        twoColumnManager.add( lblOpcionesAdicionales );
        
        buttonSet = new ListStyleButtonSetScrollManager();
        buttonSet.setScreen(this);
        
        llenar_opciones_adicionales();
                
        _foreground.add(twoColumnManager);
        add(_foreground);
        
	}
	protected void makeMenu(Menu menu, int instance) 
	{
		MenuItem enviar_email = new MenuItem("Enviar un Email al Corredor?", 0, 0) 
		{
			public void run() 
			{
				enviar_email(laPoliza.getSeguro().getCorredor().getEmailPersona());
			}
		};
		
		MenuItem llamar_telefono_seguro_1 = new MenuItem("Llamar al Telefono del Seguro "+laPoliza.getSeguro().getTelefono_Seguro_1()+"?", 0, 0) 
		{
			public void run() 
			{
				llamar_numero(laPoliza.getSeguro().getTelefono_Seguro_1());
			}
		};
		MenuItem llamar_telefono_seguro_2 = new MenuItem("Llamar al Telefono del Seguro "+laPoliza.getSeguro().getTelefono_Seguro_2()+"?", 0, 0) 
		{
			public void run() 
			{
				llamar_numero(laPoliza.getSeguro().getTelefono_Seguro_2());
			}
		};
		MenuItem llamar_telefono_corredor_1 = new MenuItem("Llamar al Telefono del Corredor "+laPoliza.getSeguro().getCorredor().getTelefono_Persona_1()+"?", 0, 0) 
		{
			public void run() 
			{
				llamar_numero(laPoliza.getSeguro().getCorredor().getTelefono_Persona_1());
			}
		};
		MenuItem llamar_telefono_corredor_2 = new MenuItem("Llamar al Telefono del Corredor "+laPoliza.getSeguro().getCorredor().getTelefono_Persona_2()+"?", 0, 0) 
		{
			public void run() 
			{
				llamar_numero(laPoliza.getSeguro().getCorredor().getTelefono_Persona_2());
			}
		};
		menu.add(enviar_email);
		menu.add(llamar_telefono_seguro_1);
		if (laPoliza.getSeguro().getTelefono_Seguro_2() != null)
		{
			menu.add(llamar_telefono_seguro_2);
		}
		menu.add(llamar_telefono_corredor_1);
		if (laPoliza.getPersona().getTelefono_Persona_2() != null)
		{
			menu.add(llamar_telefono_corredor_2);
		}
		super.makeMenu(menu, instance);
	}
	public void setListComponents()
	{
        Font font = getFont().derive(Font.PLAIN, 6, Ui.UNITS_pt);
        
		int width = font.getAdvance("Telefono: ");
		
        lblNombreSeguro = new CustomListElement("Seguro", laPoliza.getSeguro().getNombre_Seguro(), width) 
        {
			protected void paintBackground( Graphics g ) 
			{

				 
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction)
			      {
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      }
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		}; 
		lblNumeroPoliza = new CustomListElement("Nro. Poliza", ""+laPoliza.getNumeroPoliza(), width) 
		{
			protected void paintBackground( Graphics g ) 
			{
				

				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblPrimaSeguro = new CustomListElement("Prima (BsF.)", Tool.getInstance().parseFloatToString(laPoliza.getPrimaSeguro()) , width) 
		{
			protected void paintBackground( Graphics g ) 
			{

				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblCantidadAsegurada = new CustomListElement("Cant. Asegurada (BsF.)", Tool.getInstance().parseFloatToString(laPoliza.getCantidadSeguro()), width) 
		{
			protected void paintBackground( Graphics g ) 
			{

				  if( _drawPosition < 0 )
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblFechaInic = new CustomListElement("Fecha de Vigencia Desde", 
				Tool.getInstance().parseDateToString(laPoliza.getFechaIncSeguro(), 6), width) 
		{
			protected void paintBackground( Graphics g ) 
			{

				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblFechaFin = new CustomListElement("Fecha de Vigencia Hasta", 
				Tool.getInstance().parseDateToString(laPoliza.getFechaFinSeguro(), 6), width) 
		{
			protected void paintBackground( Graphics g ) 
			{

				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};		
		lblNroTlfSeguro1 = new CustomListElement("Telefono Seguro Primario", laPoliza.getSeguro().getTelefono_Seguro_1(), width) 
		{
			protected boolean keyDown(int keycode,int time) 
			{
				// keycode == 1114112 para el send
				if(keycode == 1114112)
				{
					
					if( Dialog.ask(
							Dialog.D_YES_NO, 
							"Desea llamar al Telefono "+laPoliza.getSeguro().getTelefono_Seguro_1()+"?") == 4)
					{
						llamar_numero(laPoliza.getSeguro().getTelefono_Seguro_1());
					}
					
										
			        return true;
				}
				else
				{
					return super.keyDown(keycode, time);
				}
			}
			protected void paintBackground( Graphics g ) 
			{
				
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblNroTlfSeguro2 = new CustomListElement("Telefono Seguro Secundaria", laPoliza.getSeguro().getTelefono_Seguro_2(), width) 
		{
			protected boolean keyDown(int keycode,int time) 
			{
				// keycode == 1114112 para el send
				if(keycode == 1114112)
				{
					
					if( Dialog.ask(
							Dialog.D_YES_NO, 
							"Desea llamar al Telefono "+laPoliza.getSeguro().getTelefono_Seguro_2()+"?") == 4)
					{
						llamar_numero(laPoliza.getSeguro().getTelefono_Seguro_2());
					}
					
										
			        return true;
				}
				else
				{
					return super.keyDown(keycode, time);
				}
			}
			protected void paintBackground( Graphics g ) 
			{
				
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblRifSeguro = new CustomListElement("Rif Seguro", laPoliza.getSeguro().getRif_Seguro(), width) 
		{
			protected void paintBackground( Graphics g ) 
			{
				
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblNombreCorredor = new CustomListElement("Nombre Corredor", laPoliza.getSeguro().getCorredor().getNombre_Persona_1()+
				", "+laPoliza.getSeguro().getCorredor().getApellido_Persona_1(), width) 
		{
			protected void paintBackground( Graphics g ) 
			{
				
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblEmailCorredor = new CustomListElement("Email", laPoliza.getSeguro().getCorredor().getEmailPersona(), width) 
		{
			
			protected void paintBackground( Graphics g ) 
			{

				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblNroTlfCorredor1 = new CustomListElement("Telefono Corredor Primario", laPoliza.getSeguro().getCorredor().getTelefono_Persona_1(), width) 
		{
			protected boolean keyDown(int keycode,int time) 
			{
				// keycode == 1114112 para el send
				if(keycode == 1114112)
				{
					
					if( Dialog.ask(
							Dialog.D_YES_NO, 
							"Desea llamar al Telefono "+laPoliza.getSeguro().getCorredor().getTelefono_Persona_1()+"?") == 4)
					{
						llamar_numero(laPoliza.getSeguro().getCorredor().getTelefono_Persona_1());
					}
					
										
			        return true;
				}
				else
				{
					return super.keyDown(keycode, time);
				}
			}
			protected void paintBackground( Graphics g ) 
			{
				
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		lblNroTlfCorredor2 = new CustomListElement("Telefono Corredor Secundario", laPoliza.getSeguro().getCorredor().getTelefono_Persona_2(), width) 
		{
			protected boolean keyDown(int keycode,int time) 
			{
				// keycode == 1114112 para el send
				if(keycode == 1114112)
				{
					
					if( Dialog.ask(
							Dialog.D_YES_NO, 
							"Desea llamar al Telefono "+laPoliza.getSeguro().getCorredor().getTelefono_Persona_2()+"?") == 4)
					{
						llamar_numero(laPoliza.getSeguro().getCorredor().getTelefono_Persona_2());
					}
					
										
			        return true;
				}
				else
				{
					return super.keyDown(keycode, time);
				}
			}
			protected void paintBackground( Graphics g ) 
			{
				
				  if( _drawPosition < 0 ) 
				  {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      int focus = Constant.COLOR_FOCUS_NORMAL;
			      if(_doAction) 
			    	  focus = Constant.COLOR_LIST_FOCUS;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : Constant.COLOR_UNFOCUS_NORMAL;
			      
			      try 
			      {
			    	  
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			          g.drawLine(_preferedWidth+SEPARATOR_LONG, 0, _preferedWidth+SEPARATOR_LONG, getHeight());
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			  }
		};
		
        

		//   Informacion de la Poliza
        _content_poliza.add( lblFechaInic );
        _content_poliza.add( lblFechaFin );
        _content_poliza.add( lblCantidadAsegurada );
        _content_poliza.add( lblPrimaSeguro );
        //   Informacion del Seguro
		_content_seguro.add( lblNombreSeguro );
		_content_seguro.add( lblRifSeguro );
		_content_seguro.add( lblNroTlfSeguro1 );
        if (laPoliza.getSeguro().getTelefono_Seguro_2() != null)
        {
        	_content_seguro.add( lblNroTlfSeguro2 );
        }
        //    Informacion del Corredor
        _content_corredor.add( lblNombreCorredor );
        _content_corredor.add( lblNroTlfCorredor1 );
        if (laPoliza.getSeguro().getCorredor().getTelefono_Persona_2() != null)
        {
        	_content_corredor.add( lblNroTlfCorredor2 );
        }
        _content_corredor.add(lblEmailCorredor);
        
        lblInformacionCorredor = new LabelField("Informacion del Corredor", USE_ALL_WIDTH | FIELD_HCENTER);
        lblInformacionCorredor.setFont(font_italic_7);
        
        lblInformacionSeguro = new LabelField("Informacion del Seguro", USE_ALL_WIDTH | FIELD_HCENTER);
        lblInformacionSeguro.setFont(font_italic_7);
        
        
        twoColumnManager.add(_content_poliza);
        twoColumnManager.add(lblInformacionSeguro);
        twoColumnManager.add(_content_seguro);
        twoColumnManager.add(lblInformacionCorredor);
        twoColumnManager.add(_content_corredor);
        

	}
	
	
	public void llenar_opciones_adicionales()
	{
		listOpcionEnvioCartaAval = new StringListStyleButtonField(
													"Solicitar Carta Aval al Corredor", 
													LabelField.ELLIPSIS) 
		{
			protected void paintBackground( Graphics g )
			{
				  COLOR_BACKGROUND_FOCUS = Constant.COLOR_LIST_FOCUS;
				  COLOR_BACKGROUND_FOCUS_ACTION = Constant.COLOR_FOCUS_NORMAL;

			      if( _drawPosition < 0 ) 
			      {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      
			      int focus = COLOR_BACKGROUND_FOCUS;
			      if(_doAction) 
			    	  focus = COLOR_BACKGROUND_FOCUS_ACTION;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : COLOR_BACKGROUND;
			      try 
			      {
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			}
		};
		listOpcionEnvioCartaAval.setChangeListener( this );
		
		
		
		listOpcionBeneficiaros = new StringListStyleButtonField("Ver Beneficiaros", LabelField.ELLIPSIS) 
		{
			protected void paintBackground( Graphics g )
			{
				  COLOR_BACKGROUND_FOCUS = Constant.COLOR_LIST_FOCUS;
				  COLOR_BACKGROUND_FOCUS_ACTION = Constant.COLOR_FOCUS_NORMAL;

			      if( _drawPosition < 0 ) 
			      {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      
			      int focus = COLOR_BACKGROUND_FOCUS;
			      if(_doAction) 
			    	  focus = COLOR_BACKGROUND_FOCUS_ACTION;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : COLOR_BACKGROUND;
			      try 
			      {
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			}
		};
		listOpcionBeneficiaros.setChangeListener( this );
		
		listOpcionClinicas = new StringListStyleButtonField("Ver Clinicas Afiliadas", LabelField.ELLIPSIS) 
		{
			protected void paintBackground( Graphics g )
			{
				  COLOR_BACKGROUND_FOCUS = Constant.COLOR_LIST_FOCUS;
				  COLOR_BACKGROUND_FOCUS_ACTION = Constant.COLOR_FOCUS_NORMAL;

			      if( _drawPosition < 0 ) 
			      {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      
			      int focus = COLOR_BACKGROUND_FOCUS;
			      if(_doAction) 
			    	  focus = COLOR_BACKGROUND_FOCUS_ACTION;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : COLOR_BACKGROUND;
			      try 
			      {
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			}
		};
		listOpcionClinicas.setChangeListener( this );
		
		listOpcionInfoCartaAval = new StringListStyleButtonField("Consultar Requisitos de la Carta Aval", LabelField.ELLIPSIS) 
		{
			protected void paintBackground( Graphics g )
			{
				  COLOR_BACKGROUND_FOCUS = Constant.COLOR_LIST_FOCUS;
				  COLOR_BACKGROUND_FOCUS_ACTION = Constant.COLOR_FOCUS_NORMAL;

			      if( _drawPosition < 0 ) 
			      {
			          // it's like a list field, let the default background be drawn
			          super.paintBackground( g );
			          return;
			      }
			      
			      int oldColour = g.getColor();
			      
			      int focus = COLOR_BACKGROUND_FOCUS;
			      if(_doAction) 
			    	  focus = COLOR_BACKGROUND_FOCUS_ACTION;
			      
			      int background = g.isDrawingStyleSet( Graphics.DRAWSTYLE_FOCUS ) ? focus : COLOR_BACKGROUND;
			      try 
			      {
			          if( _drawPosition == 0 ) 
			          {
			              // Top
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else if( _drawPosition == 1 ) 
			          {
			              // Bottom 
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			          } 
			          else if( _drawPosition == 2 ) 
			          {
			              // Middle
			              g.setColor( background );
			              g.fillRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, -CORNER_RADIUS, getWidth(), getHeight() + 2 * CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS );
			              g.drawLine( 0, getHeight() - 1, getWidth(), getHeight() - 1 );
			          } 
			          else 
			          {
			              // Single
			              g.setColor( background );
			              g.fillRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			              g.setColor( COLOR_BORDER );
			              g.drawRoundRect( 0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS );
			          }
			      } 
			      finally 
			      {
			          g.setColor( oldColour );
			      }
			}
		};
		listOpcionInfoCartaAval.setChangeListener( this );
		
		buttonSet.add(listOpcionBeneficiaros);
		buttonSet.add(listOpcionClinicas);
		buttonSet.add(listOpcionEnvioCartaAval);
		buttonSet.add(listOpcionInfoCartaAval);
		
		twoColumnManager.add(buttonSet);
		
	}
	
	private void refrescar_lista_choice()
	{
		if (UserInfoCache.getInstance().getListaFamiliar().cantElementListaFamiliar() == 0)
		{
			ListaFamiliarScreenHandler handler_familiar = new ListaFamiliarScreenHandler();
			handler_familiar.refreshListaFamiliar(UserInfoCache.getInstance().getUsuario().getNombre_Usuario(), 
												UserInfoCache.getInstance().getUsuario().getPassword(), 3);
		}
		
		if (UserInfoCache.getInstance().getPoliza().getSeguro().getListadoHospital().cantElementListaHospital() == 0)
		{
			ListaHospitalScreenHandler handler_hospital = new ListaHospitalScreenHandler();
			handler_hospital.refreshListaHospital(UserInfoCache.getInstance().getUsuario().getNombre_Usuario(), 
											UserInfoCache.getInstance().getUsuario().getPassword(), 
											UserInfoCache.getInstance().getPoliza().getSeguro().getIdSeguro(), 
											2);
		}
	}
	
	public void fieldChanged( Field field, int context ) 
	{
		switch (field.getIndex())
		{
			case 0: // Consultar Beneficiaros
				ListaFamiliarScreenHandler handler0 = new ListaFamiliarScreenHandler();
				handler0.getListaFamiliar(UserInfoCache.getInstance().getUsuario().getNombre_Usuario(), 
											UserInfoCache.getInstance().getUsuario().getPassword(), 
											2);
				
				break;
			case 1: // Consultar Clinicas
				ListaHospitalScreenHandler handler1 = new ListaHospitalScreenHandler();
				handler1.getListaHospital(
							UserInfoCache.getInstance().getUsuario().getNombre_Usuario(), 
							UserInfoCache.getInstance().getUsuario().getPassword(), 
							laPoliza.getSeguro().getIdSeguro(),1);
				break;
			case 2: // Envio Carta Aval

					
					DetailPolizaScreenHandler handler = new DetailPolizaScreenHandler();
					handler.getListaHospitalBeneficiarios(UserInfoCache.getInstance().getUsuario().getNombre_Usuario(), 
															UserInfoCache.getInstance().getUsuario().getPassword(), 
															laPoliza);
				break;
			case 3: // Informacion Carta Aval

				ScreenEngine.getInstance().goPantallaInfoCartaAval();
			break;
		}
	}	

}
